<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>微信公众号支付</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <style>
        .msg {
            display: flex;
            justify-content: center;
            align-items: center;
            height: 90vh;
            margin: 0;
        }
    </style>
</head>
<body>
    <div class="msg">
        <p id="msgok" style="display: none;">支付成功，请点击左上角 ✘ 返回游戏</p>
        <p id="msgfail" style="display: none;">支付失败，请点击左上角 ✘ 返回游戏</p>
    </div>
<script type="text/javascript">
    function onBridgeReady(){
       WeixinJSBridge.invoke(
            'getBrandWCPayRequest', {
                "appId":"{{ $bridge['appId'] }}", //公众号名称，由商户传入
                "timeStamp":"{{ $bridge['timeStamp'] }}", //时间戳，自1970年以来的秒数
                "nonceStr":"{{ $bridge['nonceStr'] }}", //随机串
                "package":"{{ $bridge['package'] }}",
                "signType":"MD5",         //微信签名方式：
                "paySign":"{{ $bridge['paySign'] }}" //微信签名
            },
          function(res){
            if(res.err_msg == "get_brand_wcpay_request:ok" ){
                // 使用以上方式判断前端返回,微信团队郑重提示：
                // res.err_msg将在用户支付成功后返回ok，但并不保证它绝对可靠。
                var msg = document.getElementById('msgok')
                msg.style.display = "block"
            }else{
                // 支付失败
                var msg = document.getElementById('msgfail')
                msg.style.display = "block"
            }


            // var url = "{{ $redirect_url }}";
            // window.location.href=url;
       });
    }
    if (typeof WeixinJSBridge == "undefined"){
        if( document.addEventListener ){
            document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
        }else if (document.attachEvent){
            document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
            document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
        }
    }else{
       onBridgeReady();
    }
</script>
</body>
</html>
